package org.jsping.music;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.jsping.entity.Music;
import org.jsping.service.impl.MusicServiceImpl;

/**
 * 根据用户请求的page信息来提供对应的页面的歌曲列表信息
 */
@WebServlet("/OfferMusic")
public class OfferMusic extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private MusicServiceImpl music = new MusicServiceImpl();
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int page = Integer.valueOf(request.getParameter("page"));
		
		List<Music> musicList = music.getMusicList(page);
		
		request.setAttribute("music", musicList);
		response.sendRedirect("index.jsp");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
